package day08;

import java.util.Scanner;

/**
 * @author tongchen
 * @create 2023-03-13 22:19
 */
public class Main {
    public static void main(String[] args) {
        //创建输入类
        Scanner scanner =new Scanner(System.in);
        String[] strings = new String[100];
        int count=0;//定义计数器
        while(scanner.hasNextLine()){
            strings[count++]=scanner.nextLine();
        }
        if(count<=1){
            System.out.println("both");
            return;
        }
        //定义标志位
        int flag=0;//flag==1,按长度，==2按照字典序，==3both
        int index1=0;
        int index2=0;//1和2分别用来判断是否满足两种排序条件
        for(int i=0;i<count-1;++i){
            if(strings[i].length()<=strings[i+1].length()){
                index1++;
            }
        }
        if(index1==count-1){
            flag+=1;
        }
        //判断第二种排序条件
        for(int i=0;i<count-1;++i){
            if(strings[i].compareTo(strings[i+1])<=0){
                index2++;
            }
        }
        if(index2==count-1){
            flag+=2;
        }
        //最后进行判断
        if(flag==0){
            System.out.println("none");
        }
        if(flag==1){
            System.out.println("lengths");
        }
        if(flag==2){
            System.out.println("lexicographically");
        }
        if (flag==3){
            System.out.println("both");
        }
    }
}
